<#include "../../select.ftl" />
<!-- Modal -->
<div class="modal-dialog wide" style="width: 1200px;">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <h4 class="modal-title" id="myModalLabel">
            <#if vipXxb??>
                <#if vipXxb.id??>
                    编辑
                <#else>
                    新增
                </#if>
            </#if>
            </h4>
        </div>
        <div class="modal-body">
            <div id="errorMessage"><#include "../../message.ftl" /></div>
            <form class="form-horizontal" role="form" id="vipXxbForm" method="post"
                  action="${absoluteContextPath}/vip/vipXxb/save">
            <#if vipXxb??>
                <#if vipXxb.id??>
                    <input type="hidden" name="id" value="${vipXxb.id?c}"/>
                <#else>
                    <input type="hidden" name="id" value=""/>
                </#if>
            </#if>


                <div class="table-responsive" id="vipXxbContent">
                <#include "vipXxb.ftl"/>
                </div>

            </form>
        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true">关闭</button>
            <button type="button" class="btn btn-primary" onclick="save();">保存</button>
        </div>
    </div>
</div>
<script>
    function save() {
        $("#" + "vipXxbForm").ajaxSubmit({
            success: function (data) {
                data = JSON.parse(data);
                if (data.returnCode == 1) {
                    $('#myModal').modal("hide");
                    $.showMessage({parentId: "showMessage", message: "信息保存成功！", type: "success"});
                    refreshTable();
                } else {
                    $.showMessage({parentId: "errorMessage", message: "<strong>错误信息</strong>：" + data.returnMsg, type: "error"});
                }
            }
        });
    }


    function funXh(cardno, packageName) {
        var data = {};
        var url = '${absoluteContextPath}/vip/vipXxb/goFind';
        data.cardno = cardno;
        data.packageName = packageName;
        $.ajax({
            url: url,
            type: 'post',
            data: data,
            success: function (data) {
                var data = JSON.parse(data);
                if (data.returnCode == 1) {
                    var obligateD = data.content.data;
                    $('#vipXxbContent').html(data.content.data);
                } else {
                    $.showMessage({parentId: "showMessage", message: "数据加载异常！", type: "success"});
                }
            }
        });
    }


    function funChoose(cardno) {
        var data = {};
        var url = '${absoluteContextPath}/vip/vipXxb/goChoose';
        data.cardno = cardno;
        $.ajax({
            url: url,
            type: 'post',
            data: data,
            success: function (data) {
                var data = JSON.parse(data);
                if (data.returnCode == 1) {
//                    console.info(data);
                    var obligateD = data.content.obligateD;
                    if (obligateD != null) {
                        if (obligateD == "1")
                            funXh(cardno, null);
                        else
                            dorefreshVip(cardno, null);
                    }
                } else {
                    $.showMessage({parentId: "showMessage", message: "数据加载异常！", type: "success"});
                }
            }
        });
    }
    $(function () {
        $("input[name=startTime]").focus(function () {
            WdatePicker({dateFmt: 'yyyy-MM-dd'});
        })
        $("input[name=tjDate]").focus(function () {
            WdatePicker({dateFmt: 'yyyy-MM-dd'});
        })
        $("input[name=endTime]").focus(function () {
            WdatePicker({dateFmt: 'yyyy-MM-dd'});
        })
        $("input[name=meetTime]").focus(function () {
            WdatePicker({dateFmt: 'yyyy-MM-dd'});
        })
        $("input[name=firstTime]").focus(function () {
            WdatePicker({dateFmt: 'yyyy-MM-dd'});
        })
        $("input[name=lastDate]").focus(function () {
            WdatePicker({dateFmt: 'yyyy-MM-dd'});
        })
        $("div[class='tooltip fade top in']").hide();
    });
</script>